package com.apex.restful.domain;
import com.apex.restful.entity.TBsdtDictionary;
import com.edu.orm.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * 
 * @author 18424
 *
 */
public interface DictionaryRepository extends CustomRepository<TBsdtDictionary,Long> {

    /**
     * 根据父节点编码查询
     * @param code
     * @return
     */
    @Query("select t from TBsdtDictionary t where t.parentCode=:code and t.state = 1 order by t.orderNum desc ")
    List<TBsdtDictionary> findAllByParentCodeOrderByOrderNumDesc(@Param("code") String code);

    /**
     * 根据节点编码查询
     * @param code
     * @return
     */
    @Query("select t from TBsdtDictionary t where t.code=:code and t.state = 1")
    List<TBsdtDictionary> findByCode(@Param("code") String code);
}
